package com.example.mrzhou.lvmm.view.adapter.surround;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mrzhou.lvmm.R;
import com.example.mrzhou.lvmm.commom.utils.ImageLoader;
import com.example.mrzhou.lvmm.entity.surround.holiday.Holiday;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Mr.zhou on 2016/10/27.
 */

public class HolidayAdapter extends RecyclerView.Adapter<HolidayAdapter.HolidayViewHolder> {

    private List<Holiday.DataBean.RouteListBean> data;
    private Context context;

    public HolidayAdapter(List<Holiday.DataBean.RouteListBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public HolidayViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new HolidayViewHolder(LayoutInflater.from(context).inflate(R.layout.item_list_sur_holiday, parent, false));
    }

    @Override
    public void onBindViewHolder(HolidayViewHolder holder, int position) {
        ImageLoader.getInstance().displayImage(data.get(position).getMiddleImage(),context,holder.ivHolidayImg);
        holder.tvHolidayType.setText(data.get(position).getProductType());
        holder.tvHolidayName.setText(data.get(position).getProductName());
        holder.tvHolidayTopic.setText(data.get(position).getTopic());
        holder.tvHolidayCheckinfo.setText(data.get(position).getCheckInInfo());
        holder.tvHolidayPrice.setText("¥"+data.get(position).getSellPrice()+"起");
    }

    @Override
    public int getItemCount() {
        return data!=null?data.size():0;
    }

    public class HolidayViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_holiday_img)
        ImageView ivHolidayImg;
        @BindView(R.id.tv_holiday_type)
        TextView tvHolidayType;
        @BindView(R.id.tv_holiday_name)
        TextView tvHolidayName;
        @BindView(R.id.tv_holiday_topic)
        TextView tvHolidayTopic;
        @BindView(R.id.tv_holiday_checkinfo)
        TextView tvHolidayCheckinfo;
        @BindView(R.id.tv_holiday_price)
        TextView tvHolidayPrice;

        public HolidayViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
